package com.example.lenovo_.healthyangel_menus;

import android.content.Intent;
import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.design.widget.Snackbar;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.example.lenovo_.healthyangel.R;
//import com.example.lenovo_.healthyangel_menus.Personal_Infor_EditActivity.ButtonListener;

public class Personal_InforActivity extends AppCompatActivity {
    private Button bt;
    private TextView tv1;//姓名
    private TextView tv2;//身高
    private TextView tv3;//体重
    private TextView tv4;//其他
    private TextView tv5;//体型
    private TextView tv6;//口味
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_personal_infor);
        Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
        toolbar.setTitle("个人信息");
        setSupportActionBar(toolbar);

        bt=(Button) findViewById(R.id.personal_infor_button);
        tv1=(TextView) findViewById(R.id.person_infor_name);
        tv2=(TextView) findViewById(R.id.personal_infor_height2);
        tv3=(TextView) findViewById(R.id.personal_infor_weight2);
        tv4=(TextView) findViewById(R.id.personal_infor_other2);
        tv5=(TextView) findViewById(R.id.personal_infor_shape2);
        tv6=(TextView) findViewById(R.id.personal_infor_taste2);

        FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
                        .setAction("Action", null).show();
            }
        });

        ButtonListener listener=new ButtonListener();
        bt.setOnClickListener(listener);

    }
    class ButtonListener implements View.OnClickListener{
        @Override
        public void onClick(View v) {
            Intent intent=new Intent(Personal_InforActivity.this,Personal_Infor_EditActivity.class);
            startActivityForResult(intent,1);
        }
    }
    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode==1&&resultCode==2){
            String name=data.getStringExtra("data1");
            String height=data.getStringExtra("data2");
            String weight=data.getStringExtra("data3");
            String other=data.getStringExtra("data4");
            String shape=data.getStringExtra("data5");
            String taste=data.getStringExtra("data6");
            tv1.setText(name);
            tv2.setText(height);
            tv3.setText(weight);
            tv4.setText(other);
            tv5.setText(shape);
            tv6.setText(taste);
        }
    }
}
